# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=pwncat-caleb
_pkgname=pwncat_cs
pkgver=v0.5.4.r11.g37f04d4
_pkgver=0.5.4
pkgrel=6
pkgdesc='A post-exploitation platform.'
arch=('any')
groups=('blackarch' 'blackarch-exploitation')
url='https://github.com/calebstewart/pwncat'
license=('custom:unknown')
depends=('python' 'python-netifaces' 'python-packaging' 'python-pycryptodome'
         'python-requests' 'python-rich' 'python-rapidjson' 'python-zodb'
         'python-zodburi' 'python-jinja' 'python-paramiko'
         'python-prompt_toolkit')
makedepends=('git' 'python-pip' 'python-build' 'python-wheel')
source=("$pkgname::git+https://github.com/calebstewart/pwncat.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
  cd $pkgname

  python -m build --wheel --outdir="$startdir/dist"
}

package() {
  cd $pkgname

  pip install \
    --verbose \
    --disable-pip-version-check \
    --no-warn-script-location \
    --ignore-installed \
    --no-compile \
    --no-deps \
    --root="$pkgdir" \
    --prefix=/usr \
    --no-index \
    --find-links="file://$startdir/dist" \
    $_pkgname

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" *.md

  find docs -type f -iname '*.rst' -exec install -Dm 644 -t \
    "$pkgdir/usr/share/doc/$pkgname/" {} \;
}

